package com.hl;

import com.hl.entity.Emp;
import com.hl.mapper.EmpMapper;
import com.hl.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;

public class Test {
    public static void main(String[] args) throws IOException {

        // 获取会话
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);

/*        Emp emp = mapper.selectEmpById(1);
        System.out.println(emp);*/

/*        List<Emp> emps = mapper.selectAllEmp();
        for (Emp emp : emps) {
            System.out.println(emp);
        }*/

/*        List<Emp> emps = mapper.selectAllEmpByInfo("龙");
        for (Emp emp : emps) {
            System.out.println(emp);
        }*/

/*        int row = mapper.addEmp(new Emp(99, "龙皓辰", 12000, "男", "研发部"));
        System.out.println(row > 0 ?"增添成功":"增添失败");*/

/*        int row = mapper.updateEmp(new Emp(99, "龙皓辰", 16000, "男", "研发部"));
        System.out.println(row > 0 ?"修改成功":"修改失败");*/

        int row = mapper.deleteEmp(99);
        System.out.println(row > 0 ?"删除成功":"删除失败");

        MybatisUtils.closeSqlSession(sqlSession);
    }
}
